package br.com.polo.contas.dominio;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

@Entity
public class Usuario implements EntidadeBase{
	
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	private String username;
	
	private String password;
	
	@Column(name = "enable", columnDefinition = "BOOLEAN")
	private boolean enable;
	
	@ManyToMany(cascade=CascadeType.ALL, fetch= FetchType.EAGER)
	  @JoinTable(
	      name="usuario_autorizacao",
	      joinColumns={@JoinColumn(name="usuario_id", referencedColumnName="id")},
	      inverseJoinColumns={@JoinColumn(name="autorizacao_id", referencedColumnName="id")})
	private List<Autorizacao> autorizacoes;

	/**
	 * @return String username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username username 
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return String password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password password 
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return boolean enable
	 */
	public boolean isEnable() {
		return enable;
	}

	/**
	 * @param enable enable 
	 */
	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	/**
	 * @return List<Autorizacao> autorizacoes
	 */
	public List<Autorizacao> getAutorizacoes() {
		return autorizacoes;
	}

	/**
	 * @param autorizacoes autorizacoes 
	 */
	public void setAutorizacoes(List<Autorizacao> autorizacoes) {
		this.autorizacoes = autorizacoes;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
}
